#include <REGX52.H>
#include "LCD1602.h"
#include "Timer0.h"
#include "Delay.h"
unsigned char sec,min,Hour;//sec=小时min=分钟hour=秒
void main()
{
	LCD_Init();
	Timer0Init();
	LCD_ShowString(1,1,"Clock");
	
	while(1)
	{
		if(Hour!=0&&Hour%60==0)
		{
			min++;
			Hour=0;
		}
		if(min!=0&&min%60==0)
		{
			sec++;
			min=0;
		}
		LCD_ShowNum(2,1,sec,2);
		LCD_ShowNum(2,4,min,2);
		LCD_ShowNum(2,7,Hour,2);
	}
}
void Int0_Rountine(void) interrupt 1
{
	static unsigned int a=0;
	TH0=(65535-1000)/256;
	TL0=(65535-1000)%256+1;
	
	a++;
	if(a>=1000)
	{
		a=0;
		Hour++;
	}
}